/**
 * 已入驻表单列配置
 */
import { AUDIT_STATUS } from '@/enum/user'

export default {
  data() {
    return {
      isEnterColums: [
        { prop: 'integralSum', label: '积分钱包余额' },
        {
          label: '开票记录',
          render: (h, { row }) => {
            const color = `color:#409eff;cursor: pointer;`
            return (
              <div>
                {row.isInvoice ? <p style="color:#fc4560;">新申请</p> : ''}
                <p style={color} onClick={() => this.toDetailInfo(row, 'InvoiceLog')}>
                  {!row.isInvoice ? '查看' : '去处理'}
                </p>
              </div>
            )
          }
        },
        {
          label: '关联客户',
          props: 'userSum',
          render: (h, { row }) => {
            return (
              <div>
                <p>{row.userSum || 0}</p>
                <p
                  style="cursor: pointer;color:#59b7fa;"
                  onClick={() => this.toDetailInfo(row, 'RelevancyClient')}
                >
                  查看
                </p>
              </div>
            )
          }
        },
        { prop: 'joinTime', label: '入驻时间' },
        {
          label: '审核状态',
          prop: 'verifyStatus',
          render: (h, { row }) => {
            const color = `color:${row.verifyStatus === 3 ? '#409eff' : '#333'}`
            return (
              <div>
                <p style={color}>{AUDIT_STATUS[row.verifyStatus]}</p>
                {row.verifyStatus === 4 ? (
                  <p
                    style="color:#2a94f4;cursor: pointer;"
                    slot="reference"
                    onClick={() => this.lookReason(row)}
                  >
                    查看理由
                  </p>
                ) : (
                  ''
                )}
              </div>
            )
          }
        },
        {
          label: '操作',
          width: '80px',
          render: (h, { row }) => {
            return (
              <div class="flex justify-between">
                <p
                  style="color:#409eff;cursor: pointer;text-decoration: underline;"
                  onClick={() => {
                    this.$router.push({
                      name: 'CompanyInfo',
                      query: { id: row.id, userId: row.userId }
                    })
                  }}
                >
                  查看
                </p>
                {row.verifyStatus === 4 ? (
                  <el-link underline={false} onClick={() => this.doThawing(row)}>
                    解冻
                  </el-link>
                ) : (
                  <el-popover
                    placement="left"
                    width="300"
                    trigger="manual"
                    v-model={row.causeVisible}
                  >
                    <div>
                      <el-input
                        type="textarea"
                        rows="3"
                        placeholder="请输入冻结理由(100字以内)"
                        v-model={this.freezeCause}
                      ></el-input>
                      <div class="flex mt-8 align-center justify-between">
                        <p>确定冻结该企业主？</p>
                        <div>
                          <el-button
                            onClick={() => {
                              this.freezeCause = ''
                              const index = this.dataSource.findIndex(el => el.id === row.id)
                              this.dataSource[index].causeVisible = false
                            }}
                          >
                            取消
                          </el-button>
                          <el-button type="primary" onClick={() => this.doFreeze(row)}>
                            确定
                          </el-button>
                        </div>
                      </div>
                    </div>
                    <p
                      style="color:#8b8ba9;cursor: pointer;"
                      slot="reference"
                      onClick={() => {
                        this.dataSource = this.dataSource.map(el => {
                          this.freezeCause = ''
                          if (el.id === row.id) {
                            return { ...el, causeVisible: true }
                          }
                          return { ...el, causeVisible: false }
                        })
                      }}
                    >
                      冻结
                    </p>
                  </el-popover>
                )}
              </div>
            )
          }
        }
      ]
    }
  }
}
